#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int IsEnglish(char ch)
    {
        if (ch >= 'A' && ch <= 'Z')
            return true;
        if (ch >= 'a' && ch <= 'z')
            return true;

        return false;
    }
    string reverseOnlyLetters(string s)
    {
        size_t begin = 0;
        size_t end = s.size() - 1;
        while (begin < end)
        {
            while (!IsEnglish(s[begin]) && begin < end)
            {
                begin++;
            }
            while (!IsEnglish(s[end]) && begin < end)
            {
                end--;
            }
            swap(s[begin], s[end]);
            begin++;
            end--;
        }
        return s;
    }
};

